package com.itheima.service.message.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.message.CommunicationDao;
import com.itheima.dao.system.UserDao;
import com.itheima.domain.message.Communication;
import com.itheima.domain.message.CommunicationExample;
import com.itheima.service.message.CommunicationService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class CommunicationServiceImpl implements CommunicationService {

    @Autowired
    private CommunicationDao communicationDao;
    @Autowired
    private UserDao userDao;

    @Override
    public Communication findById(String id) {
        return communicationDao.selectByPrimaryKey(id);
    }

    @Override
    public void save(Communication communication) {
        communicationDao.insertSelective(communication);
    }

    @Override
    public void update(Communication communication) {
        communicationDao.updateByPrimaryKeySelective(communication);
    }

    @Override
    public void delete(String id) {
        communicationDao.deleteByPrimaryKey(id);
    }

    @Override
    public List<Communication> findAll(CommunicationExample example) {
        return communicationDao.selectByExample(example);
    }

    @Override
    public PageInfo findByPage(int pageNum, int pageSize, CommunicationExample example) {
        PageHelper.startPage(pageNum, pageSize);
        List<Communication> list = communicationDao.selectByExample(example);
        return new PageInfo(list, 10);
    }

    @Override
    public List<Communication> findUnread(String id) {
        return communicationDao.findUnread(id);
    }

    //@Override
    //public List<CommunicationProductVo> findCommunicationProductVo(String inputDate, String companyId) {
    //    return communicationDao.findCommunicationProductVo(inputDate,companyId);
    //}
}
